home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / source / tsm23s.lha / TSMorph.h < prev    next >
C/C++ Source or Header  |  1993-10-08  |  26KB  |  953 lines

  1. // TSMorph - Amiga Morphing program
  2. // Copyright (C) © 1993  Topicsave Limited
  3.  
  4. // This program is free software; you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation; either version 2 of the License, or
  7. // any later version.
  8.  
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. // GNU General Public License for more details.
  13.  
  14. // You should have received a copy of the GNU General Public License
  15. // along with this program; if not, write to the Free Software
  16. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18. // mpaddock@cix.compulink.co.uk
  19.  
  20. //    $Author: M_J_Paddock $
  21. //    $Date: 1993/08/28 22:13:35 $
  22. //    $Revision: 1.13 $
  23.  
  24. #ifndef TSMORPH_H
  25. #define TSMORPH_H
  26.  
  27. /* All the Amiga stuff    */
  28. #define INTUI_V36_NAMES_ONLY
  29. #define INTUITION_IOBSOLETE_H
  30. #include <exec/types.h>
  31. #include <exec/memory.h>
  32. #include <exec/execbase.h>
  33. #include <intuition/intuition.h>
  34. #include <intuition/classes.h>
  35. #include <intuition/classusr.h>
  36. #include <intuition/gadgetclass.h>
  37. #include <intuition/imageclass.h>
  38. #include <intuition/icclass.h>
  39. #include <devices/input.h>
  40. #include <workbench/workbench.h>
  41. #include <workbench/startup.h>
  42. #include <libraries/gadtools.h>
  43. #include <graphics/scale.h>
  44. #include <libraries/asl.h>
  45. #include <libraries/amigaguide.h>
  46. #include <libraries/reqtools.h>
  47. #include <libraries/dctv.h>
  48.  
  49. /* Various stuff is not defined in 2.02 headers    */
  50. #ifndef PGA_NewLook
  51. #define PGA_NewLook (PGA_Dummy + 0x000A)
  52. #endif
  53.  
  54. #ifndef GTMN_FullMenu
  55. #define GTMN_FullMenu GT_TagBase+62
  56. #endif
  57.  
  58. #ifndef WA_MenuHelp
  59. #define WA_MenuHelp (WA_Dummy + 0x2F)
  60. #endif    
  61.  
  62. #ifndef WA_NewLookMenus
  63. #define WA_NewLookMenus (WA_Dummy + 0x30)
  64. #endif
  65.  
  66. #ifndef GTMN_NewLookMenus
  67. #define GTMN_NewLookMenus GT_TagBase+67
  68. #endif
  69.  
  70. #ifndef STRINGA_ExitHelp
  71. #define STRINGA_ExitHelp (STRINGA_Dummy + 0x0013)
  72. #endif
  73.  
  74. #ifndef GT_Underscore
  75. #define GT_Underscore GT_TagBase+64
  76. #endif
  77.  
  78. #ifndef IDCMP_GADGETHELP
  79. #define IDCMP_GADGETHELP 0x04000000
  80. #endif
  81.  
  82. #if INCLUDE_VERSION < 39
  83. void HelpControl(struct Window *w,ULONG flags);
  84. #pragma libcall IntuitionBase HelpControl 33C 0802
  85. #endif
  86.  
  87. #ifndef HC_GADGETHELP
  88. #define HC_GADGETHELP 1
  89. #endif
  90.  
  91. /* prototypes    */
  92. #include <clib/exec_protos.h>
  93. #include <clib/dos_protos.h>
  94. #include <clib/layers_protos.h>
  95. #include <clib/graphics_protos.h>
  96. #include <clib/intuition_protos.h>
  97. #include <clib/input_protos.h>
  98. #include <clib/gadtools_protos.h>
  99. #include <clib/asl_protos.h>
  100. #include <clib/utility_protos.h>
  101. #include <clib/diskfont_protos.h>
  102. #include <clib/icon_protos.h>
  103. #include <clib/amigaguide_protos.h>
  104. #include <clib/alib_protos.h>
  105. #include <clib/reqtools_protos.h>
  106. #include <clib/dctv_protos.h>
  107.  
  108. /* Pragmas    */
  109. #include <pragmas/exec_pragmas.h>
  110. #include <pragmas/dos_pragmas.h>
  111. #include <pragmas/layers_pragmas.h>
  112. #include <pragmas/graphics_pragmas.h>
  113. #include <pragmas/intuition_pragmas.h>
  114. #include <pragmas/input_pragmas.h>
  115. #include <pragmas/gadtools_pragmas.h>
  116. #include <pragmas/asl_pragmas.h>
  117. #include <pragmas/utility_pragmas.h>
  118. #include <pragmas/diskfont_pragmas.h>
  119. #include <pragmas/icon_pragmas.h>
  120. #include <pragmas/amigaguide_pragmas.h>
  121. #include <pragmas/reqtools.h>
  122. #include <pragmas/dctv_pragmas.h>
  123.  
  124. #include <rexx/errors.h>
  125. #include <pragmas/rexxsyslib_pragmas.h>
  126. #include <clib/rexxsyslib_protos.h>
  127.  
  128. /* 2.02 Icon headers    */
  129. #if INCLUDE_VERSION < 37
  130. BOOL DeleteDiskObject(UBYTE *name);
  131. #pragma libcall IconBase DeleteDiskObject 8A 801
  132. #endif
  133.  
  134. /* Below is not in the 2.02 version of clib/utility_protos.h
  135.                                        pragmas/utility_pragmas.h */
  136. #if INCLUDE_VERSION < 37
  137. LONG Stricmp(UBYTE *string1,UBYTE *string2);
  138. #pragma libcall UtilityBase Stricmp A2 9802
  139. #endif
  140.  
  141. /* Standard headers    */
  142. #include <stddef.h>
  143. #include <string.h>
  144. #include <stdio.h>
  145.  
  146. /* OpalVision            */
  147. #include <opal/opallib.h>
  148.  
  149. /* define max if not already defined    */
  150. #ifndef max
  151. #define max(a,b) ((a)>(b)?(a):(b))
  152. #endif
  153.  
  154. /* IFF stuff                    */
  155. #include "iffp/ILBMapp.h"
  156.  
  157. /* GUI stuff from GadTools    */
  158. #include "gui.h"
  159.  
  160. /* defines for the IDs of the gadgets in the control window    */
  161. #define ONEGADGET        1
  162. #define TWOGADGET        2
  163. #define RELGADGET        3
  164. #define ADDGADGET        4
  165. #define DELGADGET        5
  166. #define LINKGADGET    6
  167. #define UNLINKGADGET    7
  168. #define NONEGADGET    8
  169. #define STGADGET        9
  170. #define PREVGADGET    10
  171. #define GOTOGADGET    11
  172. #define NEXTGADGET    12
  173. #define LASTGADGET    13
  174.  
  175. /* Defined externally    */
  176. extern struct Library *DOSBase;
  177. extern struct Library *SysBase;
  178.  
  179. /*    Structure definitions    */
  180.  
  181. /* Picture structure
  182.  * This holds all information for a picture displayed in a window
  183.  */
  184. struct Picture {                        // Structure used for each picture
  185.     struct Screen        *Screen;        // Screen to display on
  186.     struct Window        *Win;            // Window
  187.     struct DrawInfo    *DRI;            // Draw Info
  188.     struct Gadget        *BotGad;        // Bottom slider gadget
  189.     struct Gadget        *SideGad;    // Side slider gadget
  190.     struct Gadget        *Lgad;        // Left arrow gadget
  191.     struct Gadget        *Rgad;        // Right arrow gadget
  192.     struct Gadget        *Ugad;        // Up arrow gadget
  193.     struct Gadget        *Dgad;        // Down arrow gadget
  194.     struct Image        *Limage;        // Left arrow
  195.     struct Image        *Rimage;        // Right arrow
  196.     struct Image        *Uimage;        // Up arrow
  197.     struct Image        *Dimage;        // Down arrow
  198.     UWORD                    Left;            // Left edge
  199.     UWORD                    Top;            // Top edge
  200.     UWORD                    XLeft;        // Old left edge
  201.     UWORD                    XTop;            // Old top edge
  202.     UWORD                    ALeft;        // Left movement 10% of window
  203.     UWORD                    ATop;            // down movement 10% of window
  204.     UWORD                    MLeft;        // Max left edge
  205.     UWORD                    MTop;            // Max top edge
  206.     struct ILBMInfo    *ilbm;        // ILBM info for iff read
  207.     UWORD                    currentg;    // Current gadgetID
  208.     char                    *filename;    // For Window title
  209.     ULONG                    JustSeconds;//    Time window was activated - to ignore first click
  210.     struct BitMap        BitMap;        // The zoomed image bitmap
  211.     struct BitScaleArgs BitScaleArgs;    // For zooming image
  212.     BOOL                    Opal;            // Set if opened by OpalLoad
  213.     struct {
  214.         WORD                Left;            // Window Zoom tags - nothing to do with Zoom
  215.         WORD                Top;
  216.         WORD                Width;
  217.         WORD                Height;
  218.     } Zoom;
  219. };
  220.  
  221. /* Point structure
  222.  * Holds all information for each point
  223.  */
  224. struct MyPoint {
  225.     struct MinNode MyNode;                // Node to link in a list
  226.     WORD x,y;                                // Coordinates in the 1st image
  227.     WORD x1,y1;                                // Coordinates in the 2nd image
  228.     struct MyPoint *p1,*p2,*p3,*p4;    // Pointers to up to 4 linked points
  229. };
  230.  
  231. /* Structure for size of system gadgets
  232.  * based on Screen resolution
  233.  * This enables windows to open with correct
  234.  * gadgets on lo-res screens
  235.  */
  236. struct gadgetsizing {
  237.     ULONG sysisize;        // tag for SYSISIZE_???RES
  238.     int sizeimagew;
  239.     int sizeimageh;
  240.     int leftimagew;
  241.     int leftimageh;
  242.     int downimagew;
  243.     int downimageh;
  244.     int rightimagew;
  245.     int rightimageh;
  246.     int upimagew;
  247.     int upimageh;
  248.     int closeimagew;
  249.     int zoomimagew;
  250.     int depthimagew;
  251.     int vscrollw;
  252.     int vscrolll;
  253. };
  254.  
  255. /* Macro for finding gadget    */
  256. #define PointInBox(x,y,mx,my,MX,MY) ((x>=mx)&&(y>=my)&&(x<=MX)&&(y<=MY))
  257.  
  258. /* Macros to access system gadget sizes    */
  259. #define SYSISIZE(n)        gs[n].sysisize
  260. #define SIZEIMAGE_W(n)    gs[n].sizeimagew
  261. #define SIZEIMAGE_H(n)    gs[n].sizeimageh
  262. #define LEFTIMAGE_W(n)    gs[n].leftimagew
  263. #define LEFTIMAGE_H(n)    gs[n].leftimageh
  264. #define DOWNIMAGE_W(n)    gs[n].downimagew
  265. #define DOWNIMAGE_H(n)    gs[n].downimageh
  266. #define UPIMAGE_W(n)        gs[n].upimagew
  267. #define UPIMAGE_H(n)        gs[n].upimageh
  268. #define RIGHTIMAGE_W(n)    gs[n].rightimagew
  269. #define RIGHTIMAGE_H(n)    gs[n].rightimageh
  270. #define CLOSEIMAGE_W(n)    gs[n].closeimagew
  271. #define ZOOMIMAGE_W(n)    gs[n].zoomimagew
  272. #define DEPTHIMAGE_W(n)    gs[n].depthimagew
  273. #define VSCROLL_W(n)        gs[n].vscrollw
  274. #define VSCROLL_L(n)        gs[n].vscrolll
  275.  
  276. /* defines for resolution for index    */
  277. #define GS_LOWRES            0
  278. #define GS_MEDRES            1
  279.  
  280. /* Pointer image structures */
  281. extern UWORD __chip Add[];
  282. extern UWORD __chip Del[];
  283. extern UWORD __chip L1[];
  284. extern UWORD __chip L2[];
  285. extern UWORD __chip Mov[];
  286. extern UWORD __chip One[];
  287. extern UWORD __chip Rel[];
  288. extern UWORD __chip Two[];
  289. extern UWORD __chip U1[];
  290. extern UWORD __chip U2[];
  291.  
  292. /* Defines for the help system nodes
  293.  * See "help.h" for the node text
  294.  */
  295. #define H_Nothing        0
  296. #define H_Main         1
  297. #define HE_IFFBMHD    2
  298. #define HE_IFFRASTER    3
  299. #define HE_IFFBODY    4
  300. #define HE_IFFCLIP    5
  301. #define HE_IFFILBM    6
  302. #define HE_IFFFileS    7
  303. #define HE_IFFTOP        8
  304. #define HE_IFFMEM        9
  305. #define H_G24File2    10
  306. #define H_Width        11
  307. #define H_Height        12
  308. #define H_Single        13
  309. #define H_Frames        14
  310. #define H_Start        15
  311. #define H_Name            16
  312. #define H_GName        17
  313. #define H_EPoints        18
  314. #define H_IClose        19
  315. #define H_IZoom        20
  316. #define H_IDepth        21
  317. #define H_IM            22
  318. #define H_IMP            23
  319. #define H_IMS            24
  320. #define H_IMPO            25
  321. #define H_IMPS            26
  322. #define H_IMPSA        27
  323. #define H_IMPA            28
  324. #define H_IMPQ            29
  325. #define H_IMPE            30
  326. #define H_P_KS            31
  327. #define H_CWindow        32
  328. #define H_EOne            33
  329. #define H_ETwo            34
  330. #define H_ERel            35
  331. #define H_EAdd            36
  332. #define H_EDel            37
  333. #define H_ELnk            38
  334. #define H_EUnl            39
  335. #define H_EMov            40
  336. #define H_CClose        41
  337. #define H_CDepth        42
  338. #define H_CM            43
  339. #define H_CMP            44
  340. #define H_CMS            45
  341. #define H_CMPO            46
  342. #define H_CMPS            47
  343. #define H_CMPSA        48
  344. #define H_CMPA            49
  345. #define H_CMPE            50
  346. #define H_CMPQ            51
  347. #define H_P_LOADS        52
  348. #define H_CMSM            53
  349. #define H_EWindow        54
  350. #define H_Horiz        55
  351. #define H_Vert            56
  352. #define H_Up            57
  353. #define H_Down            58
  354. #define H_Left            59
  355. #define H_Right        60
  356. #define H_EClose        61
  357. #define H_EZoom        62
  358. #define H_EDepth        63
  359. #define H_ESize        64
  360. #define H_P_SAVES        65
  361. #define H_P_SAVESAS    66
  362. #define H_CME            67
  363. #define H_CMEG            68
  364. #define H_RAG            69
  365. #define H_RAGGX        70
  366. #define H_RAGGY        71
  367. #define H_RAGGOK        72
  368. #define H_RAGGCA        73
  369. #define H_RAGGCL        74
  370. #define H_RAGGDE        75
  371. #define H_IMPN            76
  372. #define H_CMPN            77
  373. #define HE_Size        78
  374. #define HE_OGrid        79
  375. #define HE_Grid0        80
  376. #define HE_MPoints    81
  377. #define H_IWindow        82
  378. #define H_FileOne        83
  379. #define H_GFileOne    84
  380. #define H_FileTwo        85
  381. #define H_GFileTwo    86
  382. #define H_24File1        87
  383. #define H_G24File1    88
  384. #define H_24File2        89
  385. #define HE_OMorph        90
  386. #define HE_Screen        91
  387. #define HE_Library    92
  388. #define HE_FileReq    93
  389. #define HE_WPort        94
  390. #define HE_IDevice    95
  391. #define HE_ISmall        96
  392. #define HE_IDifferent    97
  393. #define HE_ZRaster    98
  394. #define HE_Menu        99
  395. #define HE_OWindow    100
  396. #define HE_MemFile    101
  397. #define HE_AllocGadget    102
  398. #define HE_AllocImage    103
  399. #define HE_LoadImage    104
  400. #define HE_AllocIFF    105
  401. #define HE_AllocILBM    106
  402. #define HE_GetDRI        107
  403. #define HE_LockScreen    108
  404. #define HE_FileFormat    109
  405. #define HE_TooSmall    110
  406. #define HE_Range        111
  407. #define HE_MemPoints    112
  408. #define HE_InvLink    113
  409. #define HE_Close        114
  410. #define HE_Open        115
  411. #define HE_Write        116
  412. #define HE_4points    117
  413. #define HE_NotLinked    118
  414. #define HE_LinkSelf    119
  415. #define HE_Linked        120
  416. #define HE_UnlinkSelf    121
  417. #define HE_MemNewPoint    122
  418. #define H_Unsaved        123
  419. #define HE_OldFormat    124
  420. #define HC_First        125
  421. #define HC_Previous    126
  422. #define HC_Goto        127
  423. #define HC_Next        128
  424. #define HC_Last        129
  425. #define H_CMEF            130
  426. #define H_CMEFF        131
  427. #define H_CMEFP        132
  428. #define H_CMEFG        133
  429. #define H_CMEFN        134
  430. #define H_CMEFL        135
  431. #define HE_OneFrame    136
  432. #define HE_FAllSize    137
  433. #define H_IMPD            138
  434. #define H_FrameNumber    139
  435. #define H_P_CP            140
  436. #define H_P_CI            141
  437. #define H_P_CIP        142
  438. #define H_P_OM            143
  439. #define H_P_PS            144
  440. #define H_P_ZO            145
  441. #define H_P_CIR        146
  442. #define H_P_DE            147
  443. #define H_P_DX            148
  444. #define H_P_DY            149
  445. #define H_P_LS            150
  446. #define H_P_MO            151
  447. #define H_P_POS        152
  448. #define H_P_PES        153
  449. #define H_P_PSR        154
  450. #define H_P_QU            155
  451. #define H_P_SF            156
  452. #define H_S_RD            157
  453. #define H_S_LS            158
  454. #define H_S_R            159
  455. #define HE_SaveSettings    160
  456. #define HE_LoadSettings    161
  457. #define HE_OpalVision    162
  458. #define HE_AllocPlanes    163
  459. #define HE_NoOpal        164
  460. #define H_P_AA            165
  461. #define HE_NoFile        166
  462. #define H_P_HE            167
  463. #define H_HelpGad        168
  464. #define H_P_Preview    169
  465. #define H_IMPP            170
  466. #define H_CMPP            171
  467. #define H_Arexx        172
  468. #define H_PCUSTM        173
  469. #define H_PCUSTD        174
  470. #define HE_OScreen    175
  471. #define HE_DrawI        176
  472. #define HE_LockW        177
  473. #define HE_ScreenMode    178
  474.  
  475. /* Defines for the Disabled Messages */
  476. #define DI_Zoom        1000
  477. #define DI_WaitSS        1001
  478. #define DI_WaitOpen    1002
  479. #define DI_WaitSave    1003
  480. #define DI_Delete        1004
  481. #define DI_About        1005
  482. #define DI_Image1        1006
  483. #define DI_Image2        1007
  484. #define DI_Draw        1008
  485. #define DI_Grid        1009
  486. #define DI_Unsaved    1010
  487. #define DI_Preview    1011
  488. #define DI_LoadBrush    1012
  489. #define DI_New            1013
  490. #define DI_GetFrame    1014
  491. #define DI_NextFrame    1015
  492.  
  493. /* TSMorph.c    */
  494.  
  495. /* Libraries    */
  496. struct Library    *IntuitionBase,
  497.                     *GfxBase,
  498.                     *LayersBase,
  499.                     *InputBase,
  500.                     *IFFParseBase,
  501.                     *GadToolsBase,
  502.                     *AslBase,
  503.                     *UtilityBase,
  504.                     *DiskfontBase,
  505.                     *AmigaGuideBase,
  506.                     *IconBase,
  507.                     *ReqToolsBase,
  508.                     *RexxSysBase,
  509.                     *DCTVBase;
  510.  
  511. struct OpalBase *OpalBase;
  512.  
  513. /* Externals defined    */
  514. extern struct gadgetsizing        gs[];            /* Size of system gadgets        */
  515. extern UWORD                         Mode;            /* Current editing mode            */
  516. extern struct List                PointList;    /* List of Points                    */
  517. extern struct Picture             Pic1,            /* 1st                                */
  518.                                         Pic2;            /* and 2nd images                    */
  519. extern BOOL                            Pic1_Open;    /* If 1st                            */
  520. extern BOOL                            Pic2_Open;    /* and 2nd images are open        */
  521. extern struct FileRequester    *filereq;    /* General use file requester    */
  522. extern BOOL                            Saved;        /* Set to FALSE after editing    */
  523. extern char                            savedfilename[256];    /* Current project file name    */
  524. extern LONG                            Width,        /* Width and                        */
  525.                                         Height;        /* Height of project                */
  526. extern LONG                            SinglePicture;    /* TRUE for Warps                */
  527. extern BOOL                            Zoom;                /* TRUE if current Zoomed    */
  528. extern BOOL                            ZoomAllowed;    /* FALSE to save memory        */
  529. extern BOOL                            PaletteAllowed;    /* FALSE for compatibility            */
  530. extern char                            **ArgArray;            /* Parameter/ToolTypes                */
  531. extern char                            **ArgArraySettings;/* From settings file                */
  532. extern AMIGAGUIDECONTEXT        handle;        /* Help handle                        */
  533. extern BOOL                            palette;        /* TRUE if Palette changed        */
  534. extern BOOL                            CreateIcons;/* TRUE if to write Icons        */
  535. extern BOOL                            CreateIconsR;/* TRUE if to write Render Icons    */
  536. extern BOOL                            CreateIconsP;/* TRUE if to write prefs Icons    */
  537. extern BOOL                            KeepSettings;/* TRUE to save settings on quit */
  538. extern ULONG                        DX;
  539. extern ULONG                        DY;
  540. extern char                            LoadScript[];
  541. extern char                            PreScript[];
  542. extern char                            PostScript[];
  543. extern char                            ScreenName[];
  544. extern char                            ScreenNameR[];
  545. extern char                            PreviewScript[];
  546. extern char                            CustomName[];
  547. extern ULONG                        CustomDepth;
  548. extern BOOL                            OpenedScreen;
  549. extern ULONG                        Depth;
  550. extern ULONG                        RenderMode;
  551. extern ULONG                        SaveFormat;
  552. extern ULONG                        Quality;
  553. extern ULONG                        ASig;            /* Amiga guide signal            */
  554. extern ULONG                        OpenMode;    /* Open mode (opal etc.)        */
  555. extern int                            changedboxcount;    // Used to redraw points after resizing BOTH windows
  556. extern UWORD                        n;                    // Holds screen resolution
  557. extern LONG                         MaxWidth;        // Max x of points
  558. extern LONG                            MaxHeight;        // Max y of points
  559. extern BOOL                            AntiAlias;        // Anti Alias?
  560. extern BOOL                            GHelp;            // Gadget Help?
  561.  
  562. /* Properties for IFF read    */
  563. extern LONG props[];
  564. extern LONG stops[];
  565. extern LONG nowt[];
  566. extern LONG FrameNumber;
  567. extern USHORT __chip BusyPointerData[];
  568.  
  569. /* Prototypes    */
  570. void About(void);
  571. void main(int argc,char **argv);
  572. BOOL openAPicture(char *filename,struct Picture *Pic,BOOL Gui);
  573. void CloseAPicture(struct Pictrue *pic);
  574. void doNewSize(struct Picture *pic);
  575. void checkGadget(struct Picture *pic);
  576. void DrawPixels(struct Picture *pic,SHORT x,SHORT y,struct MyPoint *MyPoint);
  577. void DeleteAllPoints(void);
  578. BOOL MyOpen(char *filename,BOOL JustPoints,BOOL Gui);
  579. BOOL SaveAs(char *filename);
  580. void MySetMode(UWORD NewMode);
  581. void doMsgLoop(void);
  582. void SetMyPointer(void);
  583. int DoMenu(struct Picture *pic,UWORD Selection);
  584. void DisableWindows(ULONG dnum);
  585. void EnableWindows(void);
  586.  
  587. /* Defines for Image movement gadgets IDS    */
  588. #define NO_GADGET                (0)
  589. #define UP_DOWN_GADGET        (1)
  590. #define LEFT_RIGHT_GADGET    (2)
  591. #define UP_GADGET                (3)
  592. #define DOWN_GADGET            (4)
  593. #define LEFT_GADGET            (5)
  594. #define RIGHT_GADGET            (6)
  595.  
  596. /* Defines for Edit mode    */
  597. #define EDIT1        1    // moving points in one window
  598. #define EDIT2        2    // moving points in both windows absolutely
  599. #define EDITREL    3    // moving points in both windows relatively
  600. #define ADD            4    // Adding points
  601. #define DELETE        5    // Deleting points
  602. #define LINK1        6    // Linking points - select 1st point
  603. #define UNLINK1    7    // Unlinkg points
  604. #define LINK2        8    // Linking points - select 2nd point
  605. #define LINK2A        9    // Linking points - 2nd point selected
  606. #define UNLINK2    10    // Unlinking points - select 2nd point
  607. #define UNLINK2A    11    // Unlinking points - 2n point selected
  608. #define NONE        12    // Just scrolling the windows
  609.  
  610. /* Defines for menu items    */
  611. #define M_PROJECT            0    // Project menu
  612.  
  613. #define MM_NEW                0
  614. #define MM_OPEN            1
  615. #define MM_B1                2
  616. #define MM_SAVE            3
  617. #define MM_SAVEAS            4
  618. #define MM_B2                5
  619. #define MM_ABOUT            6
  620. #define MM_B3                7
  621. #define MM_EXITPOINTS    8
  622. #define MM_B4                9
  623. #define MM_QUIT            10
  624. #define MM_B5                11
  625. #define MM_PPREVIEW        12
  626.  
  627. #define M_EDIT                1    // Edit menu
  628.  
  629. #define MM_GRID            0
  630. #define MM_FRAME            1    // Frame sub-menu
  631.  
  632. #define MI_FIRST            0
  633. #define MI_PREV            1
  634. #define MI_GOTO            2
  635. #define MI_NEXT            3
  636. #define MI_LAST            4
  637.  
  638. #define MM_MODE            2    // Mode sub-menu
  639.  
  640. #define MI_EDITONE        0
  641. #define MI_EDITTWO        1
  642. #define MI_EDITREL        2
  643. #define MI_ADD                3
  644. #define MI_DELETE            4
  645. #define MI_LINK            5
  646. #define MI_UNLINK            6
  647. #define MI_NONE            7
  648.  
  649. #define M_SETTINGS        2    // Settings menu
  650.  
  651. #define MM_ICONS            0
  652. #define MM_PALETTE        1
  653. #define MM_ZOOM            2
  654. #define MM_OPENMODE        3
  655.  
  656. #define MI_ALWAYS            0
  657. #define MI_IFILBM            1
  658. #define MI_IFCOLOURS        2
  659. #define MI_REMAP            3
  660. #define MI_OPAL            4
  661.  
  662. #define MM_SCREEN            4
  663. #define MM_CUSTOM            5
  664. #define MM_CDEPTH            6
  665. #define MM_SPREVIEW        7
  666.  
  667. #define MM_C1                8
  668. #define MM_ICONSP            9
  669. #define MM_KEEPS            10
  670. #define MM_LOADS            11
  671. #define MM_SAVES            12
  672. #define MM_SAVESAS        13
  673. #define MM_C2                14
  674. #define MM_ICONSR            15
  675. #define MM_DX                16
  676. #define MM_DY                17
  677. #define MM_LOADSCRIPT    18
  678. #define MM_PRESCRIPT        19
  679. #define MM_POSTSCRIPT    20
  680. #define MM_DEPTH            21
  681. #define MM_RENDERMODE    22
  682.  
  683. #define MI_MODE0            0
  684. #define MI_MODE1            1
  685. #define MI_MODE2            2
  686. #define MI_MODE3            3
  687.  
  688. #define MM_SAVEFORMAT    23
  689.  
  690. #define MI_ILBM24            0
  691. #define MI_OPAL24            1
  692. #define MI_OPAL24T        2
  693. #define MI_OPAL24F        3
  694. #define MI_OPAL24FT        4
  695. #define MI_JPEG            5
  696. #define MI_JPEGT            6
  697. #define MI_PBM                7
  698. #define MI_BW16            8
  699. #define MI_BW256            9
  700. #define MI_HAM6            10
  701. #define MI_HAM8            11
  702. #define MI_DCTV3            12
  703. #define MI_DCTV4            13
  704.  
  705. #define MM_QUALITY        24
  706. #define MM_SCREENR        25
  707. #define MM_ANTIALIAS        26
  708. #define MM_C3                27
  709. #define MM_RESETD            28
  710. #define MM_LASTS            29
  711. #define MM_RESTORE        30
  712. #define MM_C4                31
  713. #define MM_HELP            32
  714.  
  715. #define OPEN_ILBM_IF_ILBM        MI_IFILBM        // Open using iffparse if an ilbm <24 bits
  716. #define OPEN_ILBM_IF_COLOURS    MI_IFCOLOURS    // Open using iffparse if less colours than screen
  717. #define OPEN_ILBM_ALWAYS        MI_ALWAYS        // Open using iffparse only
  718. #define OPEN_REMAP                MI_REMAP            // Remap if possible
  719. #define OPEN_OPAL                    MI_OPAL            // Always use opal.library and remap
  720.  
  721. /* Subroutines.c    */
  722.  
  723. extern char TempFilename[256];        // File name used to get a file name
  724.  
  725. /* Prototypes    */
  726. void ihelp(ULONG helpnum);
  727. void help(ULONG helpnum);
  728. void ColorWindow(struct Picture *pic);
  729. void UnColorWindow(struct Picture *pic);
  730. void MyArgArrayInit(int argc,char **argv);
  731. void MyArgArrayDone(void);
  732. UBYTE *MyArgString(UBYTE *arg2,UBYTE *arg3,BOOL reopen);
  733. LONG MyArgInt(UBYTE *arg2, long arg3,BOOL reopen);
  734. BOOL MyFindToolType(UBYTE *arg2,BOOL reopen);
  735. void OpenNewArgs(UBYTE *filename);
  736. void CloseWindowSafely(struct Window *win);
  737. void StripIntuiMessages(struct MsgPort *mp,struct Window *win);
  738. void Error(char *ErrorMessage,char *Gadget,char *extra,ULONG helpnum);
  739. void XError(struct Picture *pic,char *ErrorMessage,char *Gadget,char *extra,ULONG helpnum);
  740. void DrawAllPoints(void);
  741. void OpenPointsEdit(void);
  742. void AddGrid(void);
  743. void ReallyAddGrid(void);
  744. void DoMenuHelp(USHORT code);
  745. BOOL SaveRequester(void);
  746. void LinkPoints(struct MyPoint* MyPoint,struct MyPoint *MyPoint1);
  747. void UnlinkPoints(struct MyPoint* MyPoint,struct MyPoint *MyPoint1,BOOL Draw);
  748. struct MyPoint *FindPoint(struct Picture *pic,WORD x,WORD y);
  749. VOID DeletePoint(struct MyPoint* MyPoint);
  750. void MyDraw(struct RastPort *rp, SHORT x, SHORT y, SHORT oldx, SHORT oldy);
  751. BOOL GetAFile(char *name,char *Prompt,ULONG flags);
  752. void LimitPoints(SHORT *x,SHORT *y,struct Picture *pic);
  753. void InitParams(BOOL firstcall);
  754. void UpdateParams(ULONG OZoom);
  755. int Preview(void);
  756. LONG SendRxMsg(char *msgtxt,BOOL IgnoreError);
  757. BOOL OpenCustomScreen(void);
  758. void CloseCustomScreen(void);
  759.  
  760. /* Brush images    */
  761. extern struct Image Add_im;
  762. extern struct Image Del_im;
  763. extern struct Image Link_im;
  764. extern struct Image None_im;
  765. extern struct Image One_im;
  766. extern struct Image Rel_im;
  767. extern struct Image Two_im;
  768. extern struct Image Unlink_im;
  769. extern struct Image st_im;
  770. extern struct Image prev_im;
  771. extern struct Image goto_im;
  772. extern struct Image next_im;
  773. extern struct Image last_im;
  774.  
  775. extern struct Image Add_imx;
  776. extern struct Image Del_imx;
  777. extern struct Image Link_imx;
  778. extern struct Image None_imx;
  779. extern struct Image One_imx;
  780. extern struct Image Rel_imx;
  781. extern struct Image Two_imx;
  782. extern struct Image Unlink_imx;
  783. extern struct Image st_imx;
  784. extern struct Image prev_imx;
  785. extern struct Image goto_imx;
  786. extern struct Image next_imx;
  787. extern struct Image last_imx;
  788.  
  789. /* LoadBrushes.c        */
  790. int myloadbrush(struct ILBMInfo *info,UBYTE *filename);
  791. void mycopysprite(struct ILBMInfo *ilbm,UWORD __chip *address,UBYTE *filaname);
  792. void mycopybrush(struct ILBMInfo *ilbm,struct Image *im,UBYTE *filename,UWORD size);
  793. void invertbrush(struct Image *im,UWORD size);
  794. void LoadBrushes(void);
  795.  
  796. /* ControlWindow.c    */
  797.  
  798. /* Gadgets    */
  799. extern struct Gadget OneGadget;
  800. extern struct Gadget TwoGadget;
  801. extern struct Gadget RelGadget;
  802. extern struct Gadget MyAddGadget;
  803. extern struct Gadget DelGadget;
  804. extern struct Gadget LinkGadget;
  805. extern struct Gadget UnlinkGadget;
  806. extern struct Gadget NoneGadget;
  807. extern struct Gadget stGadget;
  808. extern struct Gadget prevGadget;
  809. extern struct Gadget gotoGadget;
  810. extern struct Gadget nextGadget;
  811. extern struct Gadget lastGadget;
  812.  
  813. /* Defines for Image sizes    */
  814. #define IMAGE_WIDTH    38        /* The width of a Control Window gadget     */
  815. #define IMAGE_HEIGHT    34        /* and the Height                                    */
  816. #define AIMAGE            15        /* Arrow image size                                */
  817.  
  818. /* Defines for menu items in array */
  819. #define NM_PPREVIEW            13
  820. #define NM_FRAME                16
  821. #define NM_CREATEICONS        32
  822. #define NM_CHANGEPALETTE    33
  823. #define NM_ZOOM                34
  824. #define NM_ILBMALWAYS        36
  825. #define NM_ILBMIFILBM        37
  826. #define NM_ILBMIFCOLOURS    38    
  827. #define NM_REMAP                39
  828. #define NM_ILBMOPAL            40
  829. #define NM_SCREEN                41
  830. #define NM_CUSTOM                42
  831. #define NM_CDEPTH                43
  832. #define NM_SPREVIEW            44
  833. #define NM_ICONSP                46
  834. #define NM_KEEPS                47
  835. #define NM_ICONSR                52
  836. #define NM_DX                    53
  837. #define NM_DY                    54
  838. #define NM_LOADSCRIPT        55
  839. #define NM_PRESCRIPT            56
  840. #define NM_POSTSCRIPT        57
  841. #define NM_DEPTH                58
  842. #define NM_MODE0                60
  843. #define NM_MODE1                61
  844. #define NM_MODE2                62
  845. #define NM_MODE3                63
  846. #define NM_ILBM24                65
  847. #define NM_OPAL24                66
  848. #define NM_OPAL24T            67
  849. #define NM_OPAL24F            68
  850. #define NM_OPAL24FT            69
  851. #define NM_OPALJPEG            70
  852. #define NM_OPALJPEGT            71
  853. #define NM_PBM                    72
  854. #define NM_BW16                73
  855. #define NM_BW256                74
  856. #define NM_HAM6                75
  857. #define NM_HAM8                76
  858. #define NM_DCTV3                77
  859. #define NM_DCTV4                78
  860. #define NM_QUALITY            79
  861. #define NM_SCREENR            80
  862. #define NM_ANTIALIAS            81
  863. #define NM_HELP                87
  864.  
  865. /* Externals defined    */
  866. extern struct NewMenu MyNewMenu[];
  867. extern struct Window    *ControlWindow;
  868. extern struct Menu     *MyMenu;
  869. extern UBYTE            *CWTitle;
  870.  
  871. /* Prototypes    */
  872. struct Window *OpenControlWindow(void);
  873. void CloseControlWindow(void);
  874. void UpdateMenuDefs(void);
  875.  
  876. /* help.c */
  877. extern unsigned char *context[];
  878. extern unsigned char *ShortHelp[];
  879. extern unsigned char *disabled[];
  880.  
  881. /* Args.c    */
  882. void argArrayDone( void );
  883. char **argArrayInit( LONG argc, char **argv );
  884.  
  885. /* Frames.c    */
  886. int FirstFrame(void);
  887. int PrevFrame(void);
  888. int GotoFrame(void);
  889. int NextFrame(void);
  890. int LastFrame(void);
  891. BOOL GetFrameNumber(void);
  892. int ReopenPictures(void);
  893. BOOL ReopenAPicture(char *filename,struct Picture *pic);
  894.  
  895. /* OpalLoad.c */
  896.  
  897. extern UWORD FileFormat;
  898.  
  899. /* recognized file formats */
  900. #define FORMAT_IFF    1
  901. #define FORMAT_JPEG    2
  902. #define FORMAT_GIF    3
  903. #define FORMAT_PPM    4
  904. #define FORMAT_TARGA    5
  905.  
  906. extern struct RastPort     RP,            // Work Rast Ports
  907.                                  TRP;
  908. extern struct BitMap TBM;                // Temp bitmap
  909. extern UBYTE *plane0;                    // Planes for temporary bit maps
  910. extern UBYTE *plane1;
  911. extern UBYTE *plane2;
  912. extern UBYTE *plane3;
  913. extern UBYTE *plane4;
  914. extern UBYTE *plane5;
  915. extern UBYTE *plane6;
  916. extern UBYTE *plane7;
  917. extern UBYTE *Array;
  918.  
  919. BOOL MyLoadBrush(struct Picture *pic,UBYTE *filename);
  920. BOOL OpalLoad(struct Picture *pic,UBYTE *filename);
  921. BOOL InitArray(UWORD w);
  922. void FreeArray(void);
  923. BOOL ChunkyToPlanar(struct Picture *pic,UWORD width,UWORD height,UBYTE *chunky);
  924. void RGBToScreen000(UBYTE *red,UBYTE *green,UBYTE *blue,UWORD Height,UWORD Width,
  925.                           UWORD maxcol,UWORD xadd,UBYTE *r,UBYTE *g,UBYTE *b);
  926. BOOL PlanarToChunky(struct Picture *pic,UWORD w,UWORD h,UBYTE *r,UBYTE *g,UBYTE *b);
  927. void PaletteToScreen000(struct RastPort *Rp,struct Picture *Pic,UWORD maxcol,
  928.                                 UBYTE *r,UBYTE *g,UBYTE *b);
  929.  
  930. /* HandleSettings.c */
  931. void RemoveMenus(void);
  932. void AddMenus(void);
  933. void UpdateSaveFormat(BOOL remove);
  934. void UpdateRenderMode(BOOL remove);
  935. void UpdateOpenMode(BOOL remove);
  936. void UnZoom(void);
  937. void ReZoom(void);
  938. void SwitchMenuItem(UWORD pos,BOOL setting,BOOL remove);
  939. void HandleSettings(UWORD Selection,struct Picture *pic);
  940. void GetANumber(char *title,ULONG *number,ULONG HelpNum);
  941. void GetAString(char *title,char *buffer,ULONG HelpNum);
  942.  
  943. void SaveSettings(char *filename);
  944. void LoadSettings(char *filename);
  945.  
  946. /* RGBToScreen020.c    */
  947. void PaletteToScreen020(struct RastPort *Rp,struct Picture *Pic,UWORD maxcol,
  948.                                 UBYTE *r,UBYTE *g,UBYTE *b);
  949. void RGBToScreen020(UBYTE *red,UBYTE *green,UBYTE *blue,UWORD Height,UWORD Width,
  950.                           UWORD maxcol,UWORD xadd,UBYTE *r,UBYTE *g,UBYTE *b);
  951.  
  952. #endif
  953.